﻿//
// Copyright (c) 2010
// by Ashish Agrawal and Chris Paterra
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
//

using System;
using CookComputing.XmlRpc;

namespace SimpleBlog.Components.MetaWeblog {

	/// <summary>
	/// Interface for MetaWeblog methods for Windows Live Writer.
	/// </summary>
	public interface IMetaWeblog {

		#region MetaWeblog API

		[XmlRpcMethod("metaWeblog.newPost", Description = "Makes a new post to a designated blog using the " + "metaWeblog API. Returns postid as a string.")]
		string AddPost(string blogid, string username, string password, Post post, bool publish);

		[XmlRpcMethod("metaWeblog.editPost", Description = "Updates an existing post to a designated blog " + "using the metaWeblog API. Returns true if completed.")]
		bool EditPost(string postid, string username, string password, Post post, bool publish);

		[XmlRpcMethod("metaWeblog.getPost", Description = "Retrieves an existing post using the metaWeblog " + "API. Returns the metaWeblog struct.")]
		Post GetPost(string postid, string username, string password);

		[XmlRpcMethod("metaWeblog.getCategories", Description = "Retrieves a list of valid Categories for a post " + "using the metaWeblog API. Returns the metaWeblog Categories " + "struct collection.")]
		CategoryInfo[] GetCategories(string blogid, string username, string password);

		[XmlRpcMethod("metaWeblog.getRecentPosts", Description = "Retrieves a list of the most recent existing post " + "using the metaWeblog API. Returns the metaWeblog struct collection.")]
		Post[] GetRecentPosts(string blogid, string username, string password, int numberOfPosts);

		[XmlRpcMethod("metaWeblog.newMediaObject", Description = "Uploads an image, movie, song, or other media " + "using the metaWeblog API. Returns the metaObject struct.")]
		MediaObjectInfo NewMediaObject(string blogid, string username, string password, MediaObject mediaobject);

		#endregion

		#region Blogger API

		[XmlRpcMethod("blogger.deletePost", Description = "Deletes a post.")]
		[return: XmlRpcReturnValue(Description = "Returns true.")]
		bool DeletePost(string key, string postid, string username, string password, bool publish);

		[XmlRpcMethod("blogger.getUsersBlogs", Description = "Returns information on all the blogs a given user " + "is a member.")]
		BlogInfo[] GetUsersBlogs(string key, string username, string password);

		[XmlRpcMethod("blogger.getUserInfo")]
		UserInfo GetUserInfo(string key, string username, string password);

		#endregion

	}

	//[XmlRpcMissingMapping(MappingAction.Ignore)]
	//public struct Enclosure {
	//     public int Length;
	//     public string Type;
	//     public string Url;
	//}

	//[XmlRpcMissingMapping(MappingAction.Ignore)]
	//public struct Source {
	//     public string Name;
	//     public string Url;
	//}

	//public struct Page {
	//     [XmlRpcMember("page_id", Description = "Id for the page.")]
	//     public object PageID;
	//     [XmlRpcMember("page_title", Description = "Title of the page.")]
	//     public string PageTitle;
	//     [XmlRpcMember("page_parent_id", Description = "Id for the parent of the page.")]
	//     public string PageParentID;
	//     [XmlRpcMember("DateCreated", Description = "Creation date of the page.")]
	//     public DateTime DateCreated;
	//}



	///// <summary>
	///// Metaweblog specific category structure
	///// </summary>
	///// <remarks></remarks>
	//public struct MetaWebLogCategoryInfo {
	//     public string Description;
	//     public string HtmlUrl;
	//     public string RssUrl;
	//}

	//public struct NewCategory {
	//     public string Name;
	//     public string Slug;
	//     public int ParentID;
	//     public string Description;
	//}



	///// <summary>
	///// Central structure to pass a post between WLW and the module
	///// </summary>
	///// <remarks></remarks>
	//[XmlRpcMissingMapping(MappingAction.Ignore)]
	//public struct Post {

	//     [XmlRpcMember("pubDate", Description = "The date to publish the blog entry.")]
	//     public DateTime PubDate;
	//     [XmlRpcMember("date_created_gmt", Description = "The GMT DateTime value when the blog entry was created.")]
	//     public DateTime DateCreatedGmt;
	//     [XmlRpcMissingMapping(MappingAction.Error)]
	//     public DateTime DateCreated;
	//     [XmlRpcMissingMapping(MappingAction.Error)]
	//     public string Description;
	//     [XmlRpcMissingMapping(MappingAction.Error)]
	//     public string Title;
	//     [XmlRpcMember("categories", Description = "Contains Categories for the post.")]
	//     public string[] Categories;
	//     [XmlRpcMember("mt_keywords", Description = "List of Keywords for the post.")]
	//     public string MtKeywords;
	//     [XmlRpcMember("mt_allow_comments", Description = "Determines if comments will be allowed for this post.  (0 = none, 1 = open, 2=closed)")]

	//     public int MtAllowComments;
	//     [XmlRpcMember("mt_allow_pings", Description = "Determines if comments will be allowed for this post.  (0 = closed, 1 = open) ")]
	//     public int MtAllowPings;
	//     //Public enclosure As enclosure
	//     public string Link;
	//     public string Permalink;
	//     [XmlRpcMember(Description = "Not required when posting. Depending on server may " + "be either string or integer. " + "Use Convert.ToInt32(postid) to treat as integer or " + "Convert.ToString(postid) to treat as string")]
	//     public object Postid;
	//     [XmlRpcMember("publish", Description = "Determines if post will be published ")]

	//     public bool Publish;

	//     /// <summary>
	//     /// Used to track an SEO friendly description of the post, usually shorter than
	//     /// the Title and formatted for SEO presentation (eg. Using-Trackbacks-1).
	//     /// Only utilized if the supportsSlug entity is set to yes in the manifest file.
	//     /// </summary>
	//     public string WpSlug;
	//     /// <summary>
	//     /// Only utilized if the supportsPassword entity is set to yes in the manifest file.
	//     /// </summary>
	//     public string WpPassword;
	//     /// <summary>
	//     /// Only utilized if the supportsPageParent entity is set to yes in the manifest file.
	//     /// </summary>
	//     [XmlRpcMember("wp_page_parent_id", Description = "Id for the parent of the page.")]
	//     public string WpPageParentID;
	//     /// <summary>
	//     /// Only utilized if the supportsPageOrder entity is set to yes in the manifest file.
	//     /// </summary>
	//     public string WpPageOrder;
	//     /// <summary>
	//     /// Only utilized if the supportsAuthor entity is set to yes in the manifest file.
	//     /// </summary>
	//     public string WpAuthorID;
	//     /// <summary>
	//     /// Only utilized if the supportsExcerpt entity is set to yes in the manifest file.
	//     /// </summary>
	//     [XmlRpcMember("mt_excerpt", Description = "Summary of the post.")]
	//     public string MtExcerpt;
	//     /// <summary>
	//     /// Only utilized if the supportsExtendedEntries entity is set to yes in the manifest file.
	//     /// </summary>
	//     public string MtTextMore;
	//     /// <summary>
	//     /// Used to manage trackback URLs.  Will only be populated if 
	//     /// supportsTrackbacks is set to yes in the manifest file.
	//     /// </summary>
	//     public string[] MtTbPingUrls;
	//     /// <summary>
	//     /// Used to track the status of the page.  This is a WordPress property.
	//     /// </summary>
	//     public string PageStatus;
	//}

	//public struct CategoryInfo {
	//     public string CategoryId;
	//     public string ParentId;
	//     public string Description;
	//     public string CategoryName;
	//     public string HtmlUrl;
	//     public string RssUrl;
	//}

	//public struct MediaObject {
	//     public string Name;
	//     public string Type;
	//     public byte[] Bits;
	//}

	//public struct MediaObjectInfo {
	//     public string Url;
	//}

}